using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WPCoco.Particles
{
    public partial class ParticleSystem
    {
        public static ParticleSystem CreateSmoke(int totalParticles) 
        {
            ParticleSystem system = new ParticleSystem();
            system.totalParticles = totalParticles;

            // duration
            system.duration = -1;

            // Emitter mode: Gravity Mode
            system.Mode = ParticleMode.Gravity;

            // Gravity Mode: gravity
            system.gravitySystemData.Gravity = Vector2.Zero;

            // Gravity Mode: radial acceleration
            system.gravitySystemData.RadialAccelerationVariation = 0;
            system.gravitySystemData.RadialAccelerationVariation = 0;

            // Gravity Mode: speed of particles
            system.gravitySystemData.Speed = 25;
            system.gravitySystemData.SpeedVariation = 10;

            // angle
            system.particleAngle = 270;
            system.particleAngleVariation = 20;

            // emitter position
            system.sourcePosition = Vector2.Zero;
            system.positionVariance = new Vector2(5, 0);

            // life of particles
            system.particleLife = 4;
            system.particleLifeVariation = 1;

            // size, in pixels
            system.startSize = 30.0f;
            system.startSizeVariation = 10.0f;
            system.endSize = 60;

            // emits per frame
            system.emissionRate = totalParticles / system.particleLife;

            // color of particles
            system.startColor.X = 0.8f;
            system.startColor.Y = 0.8f;
            system.startColor.Z = 0.8f;
            system.startColor.W = 1.0f;
            system.startColorVariation.X = 0.02f;
            system.startColorVariation.Y = 0.02f;
            system.startColorVariation.Z = 0.02f;
            system.startColorVariation.W = 0.0f;

            system.endColor.X = 0.0f;
            system.endColor.Y = 0.0f;
            system.endColor.Z = 0.0f;
            system.endColor.W = 1.0f;
            system.endColorVariation.X = 0.0f;
            system.endColorVariation.Y = 0.0f;
            system.endColorVariation.Z = 0.0f;
            system.endColorVariation.W = 0.0f;

            system.isAdditive = false;

            return system;
        }

        public static ParticleSystem CreateGalaxy(int totalParticles) 
        {
            ParticleSystem system = new ParticleSystem();
            system.TotalParticles = totalParticles;

            // duration
            system.duration = -1;

            // Gravity Mode
            system.Mode = ParticleMode.Gravity;

            // Gravity Mode: gravity
            system.gravitySystemData.Gravity = Vector2.Zero;

            // Gravity Mode: speed of particles
            system.gravitySystemData.Speed = 60;
            system.gravitySystemData.SpeedVariation = 10;

            // Gravity Mode: radial
            system.gravitySystemData.RadialAcceleration = -80;
            system.gravitySystemData.RadialAccelerationVariation = 0;

            // Gravity Mode: tagential
            system.gravitySystemData.TangencialAcceleration = 80;
            system.gravitySystemData.TangencialAccelerationVariation = 0;

            // angle
            system.particleAngle = 270;
            system.particleAngleVariation = 360;

            // emitter position
            /*
            CCSize winSize = CCDirector.sharedDirector().getWinSize();
            this.position = new CCPoint(winSize.width / 2, winSize.height / 2);
            PosVar = new CCPoint(0, 0);
             */
            system.positionVariance = Vector2.Zero;

            // life of particles
            system.particleLife = 4;
            system.particleLifeVariation = 1;

            // size, in pixels
            system.StartSize = 37.0f;
            system.StartSizeVariation = 10.0f;
            system.EndSize = -1;

            // emits per second
            system.EmissionRate = totalParticles / system.particleLife;

            // color of particles
            system.StartColor = new Vector4(0.12f,
                                            0.25f,
                                            0.76f,
                                            1.0f);
            system.startColorVariation = Vector4.Zero;
            system.endColor = new Vector4(0,
                                          0,
                                          0,
                                          1.0f);
            system.endColorVariation = Vector4.Zero;

            // additive
            system.IsAdditive = true;

            return system;
        }

        public static ParticleSystem CreateSnow(int totalParticles) 
        {
            ParticleSystem system = new ParticleSystem();
            system.TotalParticles = totalParticles;

            system.Duration = -1;

            // set gravity mode.
            system.Mode = ParticleMode.Gravity;

            // Gravity Mode: gravity
            system.gravitySystemData.Gravity = new Vector2(0, 1);

            // Gravity Mode: speed of particles
            system.gravitySystemData.Speed = 5;
            system.gravitySystemData.SpeedVariation = 1;

            // Gravity Mode: radial
            system.gravitySystemData.RadialAcceleration = 0;
            system.gravitySystemData.RadialAccelerationVariation = 1;

            // Gravity mode: tagential
            system.gravitySystemData.TangencialAcceleration= 0;
            system.gravitySystemData.TangencialAccelerationVariation = 1;

            // emitter position
            system.positionVariance = new Vector2(Screen.Width / 2, 0);

            // angle
            system.particleAngle = 90;
            system.particleAngleVariation = 5;

            // life of particles
            system.particleLife = 45;
            system.particleLifeVariation = 15;

            // size, in pixels
            system.startSize = 10.0f;
            system.startSizeVariation = 5.0f;
            system.EndSize = -1;

            // emits per second
            system.EmissionRate = 10;

            // color of particles
            system.startColor = new Vector4(1);
            system.startColorVariation = Vector4.Zero;
            system.endColor = new Vector4(1, 1, 1, 0);
            system.endColorVariation = Vector4.Zero;

            // additive
            system.isAdditive = false;
            return system;
        }

        public static ParticleSystem CreateSun(int totalParticles) 
        {
            ParticleSystem system = new ParticleSystem();
            system.TotalParticles = totalParticles;

            // additive
            system.isAdditive = true;

            // duration
            system.Duration = -1;

            // Gravity Mode
            system.Mode = ParticleMode.Gravity;

            // Gravity Mode: gravity
            system.gravitySystemData.Gravity = Vector2.Zero;

            // Gravity mode: radial acceleration
            system.gravitySystemData.RadialAcceleration = 0;
            system.gravitySystemData.RadialAccelerationVariation = 10;
            system.gravitySystemData.TangencialAcceleration = 0;
            system.gravitySystemData.TangencialAccelerationVariation = 10;

            // Gravity mode: speed of particles
            system.gravitySystemData.Speed = 20;
            system.gravitySystemData.SpeedVariation = 5;

            // angle
            system.particleAngle = 270;
            system.particleAngleVariation = 360;

            // life of particles
            system.particleLife = 3.5f;
            system.particleLifeVariation = 0.1f;

            // size, in pixels
            system.startSize = 150.0f;
            system.startSizeVariation = 2.0f;
            system.endSize = 1;
            system.endSizeVariation = 20;

            // emits per seconds
            system.emissionRate = totalParticles / system.particleLife;

            // color of particles
            system.StartColor = new Vector4(0.76f, 0.25f, 0.12f, 1.0f);
            system.StartColorVariation = Vector4.Zero;
            system.EndColor = new Vector4(0, 0, 0, 1);
            system.EndColorVariation = Vector4.Zero;
            
            return system;
        }
    }
}
